module "WS",package.seeall

require "lfs"

class WS
	-- Constructor
	-- class variables:
	-- @dirs table holds array of files name to handle
	new: =>
		@dirs = {}
		@source = ""
		@target = ""

	-- pwd
	-- print current working directory
	pwd:()=>
      pwd = lfs.currentdir!
      print(pwd)
		
	-- link
	-- making symbolic link,s as source file,t as target file
	link:(s,t)=>
      lfs.link s,t,1
	
	mkdp:(path)=>
		lfs.mkdir path

	-- walk
	-- walk through a directory
	-- if is directory, continue searching the subdirectories and files
	-- getting attributes and show them
	walk:(path)=>
		for file in lfs.dir path
			if file != "." and file != ".."
				filepath = path.."/"..file
				attr = lfs.attributes filepath
				if attr.mode == "directory"
					@walk filepath
				else
					for i,v in pairs attr
						print i,v

	--checking os
	--uname 
	--ostypes are Darwin,Linux,Windows
	checkos:(v)=>
		switch v
			when "Linux" then return "Linux"
			when "Darwin" then return "Darwin" 
			when "Windows" then retrun "Windows"
